import { getModuleRight } from '@/store'

function checkPermission(el, binding) {
  // el.innerText = 'hello,' + binding.value
  // el.title = binding.value
  const hasPermission = getModuleRight(binding.value) > 0
  if (!hasPermission) {
    // console.log('-- no permission --', binding.value)
    el.parentNode && el.parentNode.removeChild(el)
  }
}

export default {
  inserted(el, binding) {
    checkPermission(el, binding)
  },
  // update(el, binding) {
  //   checkPermission(el, binding)
  // }
}
